extends CharacterBody2D
@export var health=100
signal hit
const RUN_SPEED=200.00
const ACCELERATION=RUN_SPEED/0.1
signal paraChanged
#定义一个parasitism，只有寄生为true时，主角才可以寄生
@export var parasitism:bool=true
@onready var animate:AnimatedSprite2D=$AnimatedSprite2D

func _ready():
	self.add_to_group("player")
	pass

func _physics_process(delta):
	var direction := Input.get_vector("左", "右", "上", "下")
	direction = direction.normalized()  # 确保方向向量长度为1，保持速度一致
	if direction != Vector2.ZERO:#get_physics_process_delta_time()
		velocity = velocity.move_toward(direction * RUN_SPEED, ACCELERATION * delta)
		move_and_slide()

func take_hit(value:int):
	health=health-value
	#$CanvasLayer/TextureProgressBar.value=health
	$FSM.change_state(4)
	pass

